home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dfpp01.zip / TIMER.H < prev   
C/C++ Source or Header  |  1992-11-21  |  796b  |  35 lines

  1. // ----------- timer.h
  2.  
  3. #ifndef TIMER_H
  4. #define TIMER_H
  5.  
  6. #include "dflatdef.h"
  7.  
  8. const int TIMER = 8;        // timer interrupt vector
  9. const int MAXTIMERS = 5;    // maximum timers at one time
  10.  
  11. class Timer    {
  12.     int timer;
  13.     static Timer *timers[MAXTIMERS];
  14.     static int timerct;
  15. #ifdef MSC
  16.     static void (interrupt *OldTimer)(INTERRUPTARGS);
  17. #else
  18.     static void interrupt (*OldTimer)(INTERRUPTARGS);
  19. #endif
  20.     friend void interrupt NewTimer(INTERRUPTARGS);
  21. public:
  22.     Timer();
  23.     ~Timer();
  24.     Bool TimedOut()             { return (Bool) (timer == 0); }
  25.     void SetTimer(int ticks) { timer = ticks; }
  26.     void DisableTimer()      { timer = -1; }
  27.     Bool TimerRunning()      { return (Bool) (timer > 0); }
  28.     void Countdown()          { --timer; }
  29.     Bool TimerDisabled()      { return (Bool) (timer == -1); }
  30. };
  31.  
  32. #endif
  33.  
  34.  
  35.